<style>
    .dropdown:hover .menu-top {
        display: block;
    }

    .dropdown-submenu{
        position:relative;
    }

    .dropdown-submenu > .dropdown-menu{
        top:0;
        left:100%;
        margin-top:-6px;
        margin-left:-1px;
        -webkit-border-radius:0 6px 6px 6px;
        -moz-border-radius:0 6px 6px 6px;
        border-radius:0 6px 6px 6px;
    }

    .dropdown-submenu:hover > .dropdown-menu{
        display:block;
    }

    .dropdown-submenu > a:after{
        display:block;
        content:" ";
        float:right;
        width:0;
        height:0;
        border-color:transparent;
        border-style:solid;
        border-width:5px 0 5px 5px;
        border-left-color:#cccccc;
        margin-top:5px;
        margin-right:-10px;
    }

    .dropdown-submenu:hover > a:after{
        border-left-color:#ffffff;
    }

    .dropdown-submenu .pull-left{
        float:none;
    }

    .dropdown-submenu.pull-left > .dropdown-menu{
        left:-100%;
        margin-left:10px;
        -webkit-border-radius:6px 0 6px 6px;
        -moz-border-radius:6px 0 6px 6px;
        border-radius:6px 0 6px 6px;
    }
</style>
<?php
    $list = Navigation();
    $list = dig($list);
    function shucho($list)
    {
        static $a = 0;
        $a++;
        $html = '';
        foreach ($list as $value) {
            if ($value['parent'] == "") {
                        $html .= "<li><a>".$value['name']."</a></li>\n";
            } else {
                if($a==1)
                    $html .= "<li class=\"dropdown\"><a class=\"dropdown-toggle\" data-toggle=\"dropdown\">".$value['name']." <b class=\"caret\"></b></a>\n";
                else
                    $html .= "<li class=\"dropdown-submenu\"><a>".$value['name']."</a>\n";
                $html .= shucho($value['parent']);
                $html .= "</li>\n";
            }
        }
        $a--;

        return $html ? ($a==0? "<ul class=\"nav navbar-nav\">$html</ul>":"<ul class=\"dropdown-menu\">\n$html</ul>\n") : $html;
    }
?>

    <nav class="navbar navbar-inverse" role="navigation" style="border-radius: 0">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">后台</a>
        </div>
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <?php
                echo shucho($list);
            ?>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">{username} <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#" onclick="out()">注销</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>

<div class="container">
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">User Admin<span style="float: right" class="glyphicon glyphicon-plus" onclick="$('#add').removeClass('sr-only')" aria-hidden="true"></span></div>

        <!-- Table -->
        <table class="table">
            <thead>
            <tr>
                <th style="width: 100px;">ID</th>
                <th>账号</th>
                <th>权限组</th>
                <th style="width: 210px;">注册时间</th>
                <th style="width: 50px;">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php
            $list = getlist();
                foreach ($list as $value){
            echo"<tr>
                    <td>".$value['id']."</td>
                    <td>".$value['username']."</td>
                    <td>".($value['group']==1 ? "管理员":"会员")."</td>
                    <td>".date('Y-m-d H:i:s', $value['regtime'])."</td>
                    <td style=\"text-align: center\"><a onclick=\"select(".$value['id'].")\"><span class=\"glyphicon glyphicon-edit\" aria-hidden=\"true\"></span></a></td>
                 </tr>";
                }
            ?>
            </tbody>
        </table>
    </div>
</div>
<div id="update" class="container col-lg-4 sr-only" style="background-color: #fff;position: absolute;top: 20%;left:35%;border: 5px dashed #ddd;padding: 20px;">
    <form id="form" action="index.php?c=user/userdo" enctype="multipart/form-data" method="post" role="form">
        <legend>修改个人资料<span style="float: right" onclick="mydelete()" class="glyphicon glyphicon-minus" aria-hidden="true"></span></legend>
        <input type="hidden" name="type" value="update"/>
        <input type="hidden" name="id" id="id" value=""/>
        <div class="form-group">
            <label for="name">呢称</label>
            <input type="text" class="form-control" name="name" id="name">
        </div>
        <div class="form-group">
            <label for="img">头像</label>
            <input type="file" name="img" id="img" accept="image/png,image/jpeg"/>
        </div>
        <div class="form-group">
            <label for="remarks">个人简介</label>
            <textarea name="remarks" id="remarks" class="form-control" style="height: 100px;"></textarea>
        </div>
        <button type="button" class="btn btn-primary" onclick="update()">修改</button>
        <button type="button" class="btn btn-primary" style="float: right" onclick="$('#update').addClass('sr-only')">关闭</button>
    </form>
</div>
<div id="add" class="container col-lg-4 sr-only" style="background-color: #fff;position: absolute;top: 20%;left:35%;border: 5px dashed #ddd;padding: 20px;">
    <div class="form-group">
        <label for="user">账号</label>
        <input type="text" class="form-control" name="user" id="user" placeholder="请填写账号" onblur="isname($('#user').val(),0)" />
        <span name="alert"></span>
    </div>

    <div class="form-group">
        <label for="pasw">密码</label>
        <input type="password" class="form-control" name="pasw" id="pasw" placeholder="请填写密码" onblur="password($('#user').val(),$('#pasw').val(),1)" />
        <span name="alert"></span>
    </div>
    <button type="button" class="btn btn-primary" onclick="add($('#user').val(),$('#pasw').val())">添加</button>
    <button type="button" class="btn btn-primary" style="float: right" onclick="$('#add').addClass('sr-only')">关闭</button>
</div>